import { ReactRouterProps } from './model';

export function findRouteByPath(routes: ReactRouterProps[] = [], path = ''): ReactRouterProps | undefined {
    for (let route of routes) {
        if (route.path === path) {
            return route;
        }
        if (route.children) {
            let res = findRouteByPath(route.children);
            if (res) {
                return res;
            }
        }
    }
}

export const checkLogin = () => {
    console.log(1231231);
    try {
        const token = localStorage.getItem('token');
        return !!token;
    } catch {
        return false;
    }
};
